package acwing.二分;

import acwing.位运算.Main;

import java.util.Scanner;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/11/18
 */
public class 数的范围 {

    static int N = 10010;
    static int n, q;
    static int []arr = new int[N];

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        n = s.nextInt();
        q = s.nextInt();

        for (int i = 0; i < n; i++) {
            arr[i] = s.nextInt();
        }
        while (q-- != 0) {
            int a = s.nextInt();
            int l = 0, r = n - 1;
            while (l < r) {
                int mid = l + r >> 1;
                if (arr[mid] >= a) r = mid;
                else l = mid + 1;
            }
            if (arr[l] == a) {
                System.out.println(l + " ");
                l = 0;
                r = n - 1;
                while (l < r) {
                    int mid = l + r + 1 >> 1;
                    if (arr[mid] <= a) l = mid;
                    else r = mid - 1;
                }
                if(arr[r] == a)
                    System.out.println(r);
            } else
                System.out.println("-1 -1");
        }
    }
}
